//
//  ZTThread.h
//  ZHYYTool
//
//  Created by MT-SW-005 on 2021/11/4.
//  Copyright © 2021 MT-SW-005. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface ZTThread : NSObject

/* ////////////////////////////////// GCD /////////////////////////////////////*/
/**
 创建串行队列
 */
+(dispatch_queue_t)createSerialQueue;


/**
创建并行队列
*/
+(dispatch_queue_t)createConcurrentQueue;


/**
获取全局并行队列
*/
+(dispatch_queue_t)getGlobalQueue;


/**
获取主队列
*/
+(dispatch_queue_t)getMainQueue;



/**
 运行同步任务
 dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
 */
+ (void)runSyncWithQueue:(dispatch_queue_t)queue block:(DISPATCH_NOESCAPE dispatch_block_t)ablock;


/**
 运行异步任务
dispatch_async(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
*/
+ (void)runAsyncWithQueue:(dispatch_queue_t)queue block:(DISPATCH_NOESCAPE dispatch_block_t)ablock;


/* ////////////////////////////////// NSThread /////////////////////////////////////*/
/**
创建线程
*/
+(NSThread*)createThreadwithTarget:(id)target selector:(SEL)aSelector object:(nullable id)argument;

/**
创建线程
*/
+(NSThread*)createThreadwithBlock:(void (^)(void))block;

/**
开始线程
*/
+(void)startThread:(NSThread*)thread;

/**
取消线程
*/
+(void)cancelThread:(NSThread*)thread;


@end

NS_ASSUME_NONNULL_END
